package com.lori.netshop.dao.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import redis.clients.jedis.JedisCluster;

import com.lori.netshop.dao.RedisDao;
@Repository
public class RedisDaoimp implements RedisDao {
	//注入redis集群
	@Autowired
	private JedisCluster rediscolony;
	/**
	 * 功能：保存string类型数据
	 */
	@Override
	public boolean set(String key, String value) {
		String set = rediscolony.set(key, value);
		if("OK".equals(set)){
			return true;
		}
		return false;
	}
	/**
	 * 获得值
	 */
	@Override
	public String get(String key) {
		return rediscolony.get(key);
	}
	/**
	 * 设置或者增加一并返回
	 */
	@Override
	public Long incr(String key) {
		Long incr = rediscolony.incr(key);
		return incr;
	}
	/**
	 * 设置或减一并返回
	 */
	@Override
	public Long decr(String key) {
		return rediscolony.decr(key);
	}
	@Override
	public Long expire(String key,int seconds) {
		return rediscolony.expire(key, seconds);
	}

	@Override
	public Long ttl(String key) {
		return rediscolony.ttl(key);
	}

	@Override
	public Long hset(String key, String field, String value) {
		return rediscolony.hset(key, field, value);
	}

	@Override
	public String hget(String key, String field) {
		return rediscolony.hget(key, field);
	}
	@Override
	public Long del(String key) {
		return rediscolony.del(key);
	}
	@Override
	public Long hdel(String key, String field) {
		return rediscolony.hdel(key, field);
	}

}
